/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package topcoder;

import java.util.ArrayList;
import java.util.Collections;

/**
 *
 * @author Mohamed.Azouz
 */
public class TallPeople {

    public int[] getPeople(String[] people) {
        int x1 = Integer.MIN_VALUE;
        int x2 = Integer.MAX_VALUE;
        ArrayList<ArrayList<Integer>> cols = new ArrayList<ArrayList<Integer>>();
        int tmpSize = people[0].split(" ").length;
        for (int i = 0; i < tmpSize; i++) {
            cols.add(new ArrayList<Integer>());
        }
        Collections.reverse(cols);
        for (int i = 0; i < people.length; i++) {
            String[] rows = people[i].split(" ");
            int min = Integer.valueOf(rows[0]);
            int tmpI = 0;
            for (String num : rows) {
                int x = Integer.valueOf(num);
                cols.get(tmpI++).add(x);
                if (min > x) {
                    min = x;
                }
            }
            if (x1 < min) {
                x1 = min;
            }
        }
        for (int i = 0; i < cols.size(); i++) {
            Integer x = Collections.max(cols.get(i));
            if (x < x2) {
                x2 = x;
            }
        }
        int [] tall={x1,x2};
        return tall;
    }

    public static void main(String[] args) {
        String people[] = {"1 1",
            "1 1"};
        TallPeople t = new TallPeople();
        t.getPeople(people);

    }
}
